﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bank.Operations
{
    public class ChangeInterestCalculation : Operation
    {
        InterestCalculationType _interestCalculationType;

        public ChangeInterestCalculation(InterestCalculationType interestingCalculationType)
        {
            _interestCalculationType = interestingCalculationType;
        }

        public override void ExecuteOperation(IAccount account)
        {
            switch (_interestCalculationType)
            {
                case InterestCalculationType.SimpleInterestCalculation:
                    var simpleInterest = new SimpleInterestCalculator();
                    account.InterestCalculator = simpleInterest;
                    break;
                case InterestCalculationType.RangeInterestCalculation:
                    var rangeInterest = new RangeInterestCalculator();
                    account.InterestCalculator = rangeInterest;
                    break;
                default:
                    return;
            }
        }

        public override void ExecuteOperation2(IAccount account)
        {
            switch (_interestCalculationType)
            {
                case InterestCalculationType.SimpleInterestCalculation:
                    var simpleInterest = new SimpleInterestCalculator();
                    account.InterestCalculator = simpleInterest;
                    break;
                case InterestCalculationType.RangeInterestCalculation:
                    var rangeInterest = new RangeInterestCalculator();
                    account.InterestCalculator = rangeInterest;
                    break;
                default:
                    return;
            }
        }


        public override string GetOperationName()
        {
            return GetType().Name;
        }
    }

    public enum InterestCalculationType
    {
        SimpleInterestCalculation,
        RangeInterestCalculation
    }

}
